#include "SFMLScoreProvider.h"
#include "stdafx.h"

SFMLScoreProvider::SFMLScoreProvider(sf::RenderWindow &window) :
_maxScore(3), _window(window)
{
	sf::Font font;
	font.loadFromFile("calibri.ttf");

	_playerScore = 0;
	_aiScore = 0;

	_playerText.setFont(font);
	_playerText.setCharacterSize(24);
	_playerText.setColor(sf::Color::Blue);
	_playerText.setOrigin(1024 / 2, 768 - 24);

	_aiText.setFont(font);
	_aiText.setCharacterSize(24);
	_aiText.setColor(sf::Color::Blue);
	_aiText.setOrigin(1024 / 2, 24);
}

void SFMLScoreProvider::GivePlayerPoint()
{
	_playerScore += 1;
	Draw();
}
void SFMLScoreProvider::GiveAIPoint()
{
	_aiScore += 1;
	Draw();
}

std::string SFMLScoreProvider::IsWinner()
{

	if (_playerScore >= _maxScore)
		return "Player";

	else if (_aiScore >= _maxScore)
		return "AI";

	return "";
}

void SFMLScoreProvider::Draw()
{
	std::ostringstream oss;
	oss << _playerScore;
	//_playerText.setString(oss.str());

	oss << _aiScore;
	//_aiText.setString(oss.str());

	_window.draw(_playerText);
	_window.draw(_aiText);
}